2.1 This project was an ambitious undertaking for David and I because we really didn’t have any experience in the majority of the concepts that we chose to cover. But, to me, that is the intent of the course: to challenge yourself. So we took on an something that wasn’t immediately obvious in how to accomplish based upon each of our programming experiences.
2.2. As I stated in the last section, I took on the chore of the server portion. It took a lot of turns and evolved into something completely different than I indented, but I am happy with the results I got.
2.3. I started the project going through the Professional C# 2008 book. I have to say, I didn’t find this book of much use. It gave some examples of the topics I wanted to cover, but it lacked in any kind of detail and, to me, left me with more questions than answers. The topic I wanted information on wasn’t even in the book. I was looking for references to Marshalling (MarshalByRefObject) and the book concentrated on COM components and how to integrate them with .Net. This was not what I was looking for because I didn’t want to create a COM object in this project. I didn’t have the time to develop a complex piece of software in the small amount of time we had to finish the project.
2.4. I did what all of us programmers do when you don’t know how to do something, I went to the internet. I did a search for client server programs and found some examples. I tried one example and it wasn’t much help. I couldn’t implement the code provided into the program like they were explaining, so the search continued.
2.5. The next search yielded the best explanation of a topic that I have found in a long time. The process didn’t give you any code to download you typed (copy/pasted) it into the project as you read along. From start to finish each step was spelled out in a clear and concise manner. I was very impressed. Armed with this knowledge of client server implementation I was able to concentrate on the next phase of the program, server communication.
2.6. To help me with this part, David sent me his code of where he was at. I had some problems getting it to work, namely getting the IP Addresses correct. Once I fixed that, I was having another problem. His program took the text that you typed and encrypted it in the socket stream. I started getting a Byte conversion error. The program was trying to convert the stream to a Byte array. The error it generated was trying to convert the stream itself, which you can’t do. After researching the problem I found that I needed to copy incoming stream data to a memory stream and then convert it to a Byte array. Once I did this I was able to convert the text to encrypted text and sent it across the network.
2.7. After I got everything working I tested it out. I was able to send messages across the network, except the receiving program would not decrypt correctly. In the debugger I saw the data come across, but somewhere along the decryption process it wiped the text out. I was at a disadvantage because I had not seen this type of encryption in action.
2.8. Instead of spinning my wheels with this I decided to get the version of my encryption implemented in my server program to continue on with the project. As I was implementing the chat portion and trying to incorporate my encryption algorithm I ran into a major problem. My encryption scheme worked with files and not streams. So I decided to take a new direction with the application.
2.9. I again turned to the internet and started searching for a program that would transfer files. I found several examples that didn’t meet my needs. But my determination paid off and I found a good example of a program that met my needs.
2.10. So here was the idea, I send a message with my chat program, encrypt it to a file, and then send it across the network. Once the file is received on the other end all I have to do is decrypt it and then display the message. So I started analyzing the code and testing it out.
2.11. The program has a simple concept; you open the server program and start the server. Then you open the client application and browse folders on your computer to send. Once you select a file the connection process takes place and the file is sent across the network. I took the concept of this program and made some modifications.
2.12. First, let’s step back a moment to the beginning of this odyssey and look at my original client server concept. While I was working with this program I implemented the encryption portion because the thought was to have the server encrypt and decrypt the data that was sent. With the client server implementation the program used a .dll library to facilitate the business layer of the project. I used this concept and placed my encryption/decryption code here. I made accessible two methods that performed these actions. To help with the new concept (the file transfer method) I had the .dll create the appropriate files. So when the program sent a message it would make a call to the server .dll and it would take the text and encrypt it. The program did a good job of this process. However when it encrypted the file it also made an encryption key to use in the decryption process. This came into play later on in the project.
2.13. I took the file transfer program and made modifications so the client would send a specific file. The server was modified to decrypt the file once it received it. This modification worked with little effort. Then I made the next logical move…I modified the client to send a file that was created with the encryption server. I made some changes and hade the program convert the text type into an encrypted file. This forked with no problem, so I had the whole process run. I fired up the server, and started it. I ran the client and typed my message and it failed to decrypt. The key it used to encrypt is created with each encryption and therefore is needed to decrypt.
2.14. Back to the drawing board with the transfer process. I had to come up with a way to transfer two files. This in itself was not a problem. The problem was on the receiving end. The program was setup to decrypt automatically when it received the file. So instead of raising the complexity of the file transfer process I chose to find a different encryption method.
2.15. I am not tied to any one method so I searched for something simple. I stuck with the Rijndael method because I have already worked with it. This example was very straight forward and allowed me to use the same parameters with the encryption and decryption so I would get the desired result without passing an encryption key with every transaction.
2.16. Now I was to the point of incorporating the two programs to meet with my project concept. During the process of testing the file transfer method I was able to run both the client and the server on my laptop which made trouble shooting a breeze. When I incorporated the file transfer server code into the main program I was able to use both parts as well. Once I added the “client” code I was unable to do this. It amounts to the server portion of the program binds to the socket it creates and when you run the second instance the program wants to bind to the same port. So the operating system won’t let you do this, so to test the program I had to use two computers.
2.17. Of course I had some problems, but nothing that really stopped me in my tracks like I had have so far. Here is the final concept I came up with:
2.18. To use the program you enter the IP address and click the connect button. This will enable the send button and allow you to send data to the other instance. If I had an additional computer (it being repaired) I would try multiple connections. In theory it should work, but I haven’t tried it.
2.19. Once everything was working I finished my portion of the project by adding the Windows event logging service. Surprisingly this turned out to be difficult as well. In Windows Vista the registry is controlled by user permissions like most other things. A program can’t create an event log without proper permission. After searching and trying a few experiments I was unable to create a log through the program. I decided to create a key in the registry manually and then have the program write to it. That worked out as anticipated and I created logging events for the start of the program and each error in the catch block. Below is a shot of my event log and an error I produced.
2.20. All in all I had quite the experience. Now David and I are going to review each other’s projects and decide on a final version to present for this project. The main difference between the two applications is implementation. I went with a file transfer method and have message logging where David went with stream encryption and registry updates. The final project will include both logging and registry updates the question will be if it is streaming encryption or file based.
Les's Project
2. Les's Project
2.1 This project was an ambitious undertaking for David and I because we really didn’t have any experience in the majority of the concepts that we chose to cover. But, to me, that is the intent of the course: to challenge yourself. So we took on an something that wasn’t immediately obvious in how to accomplish based upon each of our programming experiences.
2.2. As I stated in the last section, I took on the chore of the server portion. It took a lot of turns and evolved into something completely different than I indented, but I am happy with the results I got.
2.3. I started the project going through the Professional C# 2008 book. I have to say, I didn’t find this book of much use. It gave some examples of the topics I wanted to cover, but it lacked in any kind of detail and, to me, left me with more questions than answers. The topic I wanted information on wasn’t even in the book. I was looking for references to Marshalling (MarshalByRefObject) and the book concentrated on COM components and how to integrate them with .Net. This was not what I was looking for because I didn’t want to create a COM object in this project. I didn’t have the time to develop a complex piece of software in the small amount of time we had to finish the project.
2.4. I did what all of us programmers do when you don’t know how to do something, I went to the internet. I did a search for client server programs and found some examples. I tried one example and it wasn’t much help. I couldn’t implement the code provided into the program like they were explaining, so the search continued.
2.5. The next search yielded the best explanation of a topic that I have found in a long time. The process didn’t give you any code to download you typed (copy/pasted) it into the project as you read along. From start to finish each step was spelled out in a clear and concise manner. I was very impressed. Armed with this knowledge of client server implementation I was able to concentrate on the next phase of the program, server communication.
2.5.1. Here is the link to the example.
2.6. To help me with this part, David sent me his code of where he was at. I had some problems getting it to work, namely getting the IP Addresses correct. Once I fixed that, I was having another problem. His program took the text that you typed and encrypted it in the socket stream. I started getting a Byte conversion error. The program was trying to convert the stream to a Byte array. The error it generated was trying to convert the stream itself, which you can’t do. After researching the problem I found that I needed to copy incoming stream data to a memory stream and then convert it to a Byte array. Once I did this I was able to convert the text to encrypted text and sent it across the network.
2.7. After I got everything working I tested it out. I was able to send messages across the network, except the receiving program would not decrypt correctly. In the debugger I saw the data come across, but somewhere along the decryption process it wiped the text out. I was at a disadvantage because I had not seen this type of encryption in action.
2.8. Instead of spinning my wheels with this I decided to get the version of my encryption implemented in my server program to continue on with the project. As I was implementing the chat portion and trying to incorporate my encryption algorithm I ran into a major problem. My encryption scheme worked with files and not streams. So I decided to take a new direction with the application.
2.9. I again turned to the internet and started searching for a program that would transfer files. I found several examples that didn’t meet my needs. But my determination paid off and I found a good example of a program that met my needs.
2.9.1. Here is the link to the example.
2.10. So here was the idea, I send a message with my chat program, encrypt it to a file, and then send it across the network. Once the file is received on the other end all I have to do is decrypt it and then display the message. So I started analyzing the code and testing it out.
2.11. The program has a simple concept; you open the server program and start the server. Then you open the client application and browse folders on your computer to send. Once you select a file the connection process takes place and the file is sent across the network. I took the concept of this program and made some modifications.
2.12. First, let’s step back a moment to the beginning of this odyssey and look at my original client server concept. While I was working with this program I implemented the encryption portion because the thought was to have the server encrypt and decrypt the data that was sent. With the client server implementation the program used a .dll library to facilitate the business layer of the project. I used this concept and placed my encryption/decryption code here. I made accessible two methods that performed these actions. To help with the new concept (the file transfer method) I had the .dll create the appropriate files. So when the program sent a message it would make a call to the server .dll and it would take the text and encrypt it. The program did a good job of this process. However when it encrypted the file it also made an encryption key to use in the decryption process. This came into play later on in the project.
2.13. I took the file transfer program and made modifications so the client would send a specific file. The server was modified to decrypt the file once it received it. This modification worked with little effort. Then I made the next logical move…I modified the client to send a file that was created with the encryption server. I made some changes and hade the program convert the text type into an encrypted file. This forked with no problem, so I had the whole process run. I fired up the server, and started it. I ran the client and typed my message and it failed to decrypt. The key it used to encrypt is created with each encryption and therefore is needed to decrypt.
2.14. Back to the drawing board with the transfer process. I had to come up with a way to transfer two files. This in itself was not a problem. The problem was on the receiving end. The program was setup to decrypt automatically when it received the file. So instead of raising the complexity of the file transfer process I chose to find a different encryption method.
2.15. I am not tied to any one method so I searched for something simple. I stuck with the Rijndael method because I have already worked with it. This example was very straight forward and allowed me to use the same parameters with the encryption and decryption so I would get the desired result without passing an encryption key with every transaction.
2.15.1. Here is the link to the example.
2.16. Now I was to the point of incorporating the two programs to meet with my project concept. During the process of testing the file transfer method I was able to run both the client and the server on my laptop which made trouble shooting a breeze. When I incorporated the file transfer server code into the main program I was able to use both parts as well. Once I added the “client” code I was unable to do this. It amounts to the server portion of the program binds to the socket it creates and when you run the second instance the program wants to bind to the same port. So the operating system won’t let you do this, so to test the program I had to use two computers.
2.17. Of course I had some problems, but nothing that really stopped me in my tracks like I had have so far. Here is the final concept I came up with:
2.18. To use the program you enter the IP address and click the connect button. This will enable the send button and allow you to send data to the other instance. If I had an additional computer (it being repaired) I would try multiple connections. In theory it should work, but I haven’t tried it.
2.19. Once everything was working I finished my portion of the project by adding the Windows event logging service. Surprisingly this turned out to be difficult as well. In Windows Vista the registry is controlled by user permissions like most other things. A program can’t create an event log without proper permission. After searching and trying a few experiments I was unable to create a log through the program. I decided to create a key in the registry manually and then have the program write to it. That worked out as anticipated and I created logging events for the start of the program and each error in the catch block. Below is a shot of my event log and an error I produced.
2.20. All in all I had quite the experience. Now David and I are going to review each other’s projects and decide on a final version to present for this project. The main difference between the two applications is implementation. I went with a file transfer method and have message logging where David went with stream encryption and registry updates. The final project will include both logging and registry updates the question will be if it is streaming encryption or file based.
Project Home Next Section